using System;

namespace DeSleeper.Library
{
    /// <summary>
    /// Represents a method that handles a generic event.
    /// </summary>
    /// <typeparam name="T">Event payload data type.</typeparam>
    /// <param name="sender">The source of the event.</param>
    /// <param name="args">Data for the cancelable event.</param>
    public delegate void DataEventHandler<T>(object sender, DataEventArgs<T> args);

    /// <summary>
    /// Contains data for an event.
    /// </summary>
    public static class DataEventArgs
    {
        /// <summary>
        /// Creates a generic event.
        /// </summary>
        /// <param name="data">The events payload data.</param>
        public static DataEventArgs<T> Create<T>(T data) { return new DataEventArgs<T>(data); }
    }

    /// <summary>
    /// Contains data for an event.
    /// </summary>
    /// <typeparam name="T">Event payload data type.</typeparam>
    public class DataEventArgs<T> : EventArgs, IDataEventArgs<T>
    {
        /// <summary>
        /// The events payload data.
        /// </summary>
        public T Data { get; private set; }

        /// <summary>
        /// Creates a generic event.
        /// </summary>
        /// <param name="data">The events payload data.</param>
        public DataEventArgs(T data)
        {
            Data = data;
        }
    }
}